package com.actions.bluetoothbox2.util;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.actions.bluetoothbox2.R;

/**
 * Created by liuyong on 2017/12/26.
 */

public class PopVoiceSelectAdapter extends BaseAdapter {


    Context context;
    int imgID[] = new int[]{R.drawable.ic_voice_1, R.drawable.ic_voice_2, R.drawable.ic_voice_3, R.drawable.ic_voice_4,
            R.drawable.ic_voice_5, R.drawable.ic_voice_6, R.drawable.ic_voice_7, R.drawable.ic_voice_8, R.drawable.ic_voice_9,
            R.drawable.ic_voice_10, R.drawable.ic_voice_11, R.drawable.ic_voice_12, R.drawable.ic_voice_13, R.drawable.ic_voice_14,
            R.drawable.ic_voice_15};

    int imgID_select[] = new int[]{R.drawable.ic_voice_select1, R.drawable.ic_voice_select2, R.drawable.ic_voice_select3,
            R.drawable.ic_voice_select4, R.drawable.ic_voice_select5, R.drawable.ic_voice_select6, R.drawable.ic_voice_select7,
            R.drawable.ic_voice_select8, R.drawable.ic_voice_select9, R.drawable.ic_voice_select10, R.drawable.ic_voice_select11,
            R.drawable.ic_voice_select12, R.drawable.ic_voice_select13, R.drawable.ic_voice_select14, R.drawable.ic_voice_select15};
    boolean[] isCheck;

    public PopVoiceSelectAdapter(Context context, boolean[] isCheck) {
        this.context = context;
        this.isCheck = isCheck;
    }

    @Override
    public int getCount() {
        return imgID.length;
    }

    @Override
    public Object getItem(int position) {
        return imgID[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_voice_select, parent, false);
        }
        ImageView img_ico = (ImageView) convertView.findViewById(R.id.img_ico);
//        TextView tv_zdy = (TextView) convertView.findViewById(R.id.tv_zdy);

        if (isCheck[position]) img_ico.setImageResource(imgID_select[position]);
        else img_ico.setImageResource(imgID[position]);

        return convertView;
    }
}
